//
//  KXTimer.m
//  ShangPin
//
//  Created by HaiJiao Chen on 12-4-12.
//  Copyright (c) 2012年 kaixin001.com. All rights reserved.
//

#import "KXTimer.h"

@implementation KXTimer

-(void)time
{
    [target performSelector:selector];
}
- (void)dealloc
{
    [timer invalidate];
    [timer release];
    [super dealloc];
}
- (void)invalidate
{
    [timer invalidate];
}
+ (KXTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)ti target:(id)aTarget selector:(SEL)aSelector forMode:(NSString *)mode
{
    KXTimer* timer = [[[KXTimer alloc] init] autorelease];
    if (timer)
    {
        timer->target = aTarget;
        timer->selector = aSelector;
        timer->timer = [[NSTimer timerWithTimeInterval:ti target:timer selector:@selector(time) userInfo:nil repeats:YES] retain];
        NSRunLoop *runner = [NSRunLoop currentRunLoop];
        [runner addTimer: timer->timer forMode:mode];
    }
    return timer;
}
@end
